import instance from "./require";
import type { shopTS, typeTS } from "../store/crmsTS";

//商品列表数据
export let http_shoplist = (): Promise<Array<shopTS>> => {
    return instance.get('/shoplist1')
}

//分类列表数据
export let http_typelist = (): Promise<Array<typeTS>> => {
    return instance.get('/typelist1')
}

//添加商品列表数据
export let http_addshoplist = (obj: shopTS): Promise<shopTS> => {
    return instance.post('/shoplist1', obj)
}

//编辑商品列表数据
export let http_enitshoplist = (obj: shopTS): Promise<shopTS> => {
    return instance.patch(`/shoplist1/${obj.id}`, obj)
}

//删除商品列表数据  delete没有返回值
export let http_delshoplist = (id: number) => {
    return instance.delete(`/shoplist1/${id}`)
}

//搜索商品列表 payload=title 返回搜索出来的数组列表
export let http_searchshoplist = (title: string): Promise<Array<shopTS>> => {
    return instance.get('/shoplist1', { params: { 'title_like': title } })
}

//添加分类列表数据
export let http_addtypelist = (obj: typeTS): Promise<typeTS> => {
    return instance.post('/typelist1', obj)
}

export let http_deltypelist = (key: string) => {
    return instance.delete(`/typelist1/${key}`)
}